package com.example.wjy.adapter;

import java.util.List;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

/**
 * author: WangJunYan
 * package: com.example.wjy.adapter
 * date: 2020/6/7
 * time: 15:52
 * 在MyTeamActivity中的ViewPager2的适配器，管理5个碎片,5个碎片都是MasterFragment
 */
public class RecommendAdapter extends FragmentStateAdapter {

    /**
     * The list of fragments of ViewPager2 in RecommendActivity.
     */
    List<Fragment> fragments;

    public RecommendAdapter(@NonNull FragmentActivity fragmentActivity,
                            List<Fragment> fragments) {
        super(fragmentActivity);
        this.fragments = fragments;
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        return fragments.get(position);
    }

    @Override
    public int getItemCount() {
        return fragments.size();
    }
}
